import { Component, OnInit, OnDestroy } from '@angular/core';
import { NavParams } from '@ionic/angular';
import { DataService } from '@services/data.service';
import { CacheService } from '@services/cache.service';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'fire-detail',
  templateUrl: 'fire-detail.html',
  styleUrls: ['fire-detail.scss']
})
export class FireDetailPage implements OnInit, OnDestroy {
  typeData;                        // 获取消防主机基础数据
  currentTab = 'fireAlarmInfos';   // 默认显示火警点
  alarms = {};                     // 获取消防主机数据
  projecetId;                      // 项目ID
  constructor(
    // public navParams: NavParams,
    public dataService: DataService,
    public activatedRoute: ActivatedRoute,
    public cacheService: CacheService
  ) {
    this.projecetId  = this.cacheService.currentProject.projectId ? this.cacheService.currentProject.projectId : 0;
    this.getFireDetail(this.projecetId);
  }

  ngOnInit() {
  }


  ionViewDidLoad() {
    console.log('ionViewDidLoad DevicePage');
  }

  /**
  * 获取消防主机数据
  * @param projecetId
  */

  getFireDetail(projecetId) {
    this.dataService.getFireDevices(projecetId, 1).subscribe(res => {
      this.typeData = res.data.deviceRealTimeDetailsInfo;
      this.alarms = res.data;
    });
  }

  switchTab(type) {
    this.currentTab = type;
  }

  ngOnDestroy() {
  }
}
